import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
kids=cv.imread("../imgs/kids.jpg")
#投射变换
rows,cols=kids.shape[:2]
#1.构建透射变换矩阵：需要自己列举出原图4个点和变换后的4个点，以便推断透射变换矩阵，注意：三个点不共线
pts1=np.float32([[5,5],[368,52],[28,387],[389,390]])
pts2=np.float32([[100,140],[300,100],[80,290],[310,300]])
M=cv.getPerspectiveTransform(pts1,pts2)
#2.warpPerspective()实现透射变换
dst=cv.warpPerspective(kids,M,(cols,rows))

plt.imshow(dst[:,:,::-1])
plt.show()